package smartcrud.spring.models.rbac;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import smartcrud.common.orm.Page;
import smartcrud.common.orm.PropertyFilter;

@Service
public class RoleServiceJdbcImpl implements RoleService {
	@Autowired
	private RoleDao rbacRoleDao;

	@Override
	public Role createRole(Role o) {
		return rbacRoleDao.createRole(o);
	}

	@Override
	public void deleteRole(Long id) {
		rbacRoleDao.deleteRole(id);
	}

	@Override
	public void updateRole(Role o) {
		rbacRoleDao.updateRole(o);
		rbacRoleDao.assignRoleWithMenus(o);
	}

	@Override
	public Role findRoleById(Long id) {
		return rbacRoleDao.findRoleById(id);
	}

	@Override
	public List<Role> findAllRoles() {
		return rbacRoleDao.findAllRoles();
	}

	@Override
	public Page<Role> findByPage(Page<Role> page, final List<PropertyFilter> filters) {
		return rbacRoleDao.findByPage(page,filters);
	}
}
